[id].vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <!-- @format -->
  2. <script lang="ts" setup>
  3. import { ArrowRight } from '@element-plus/icons-vue'
  4. import { getGoodsDetailApi } from '~/api/model/goods'
  5. import { getBrandDetailApi } from '~/api/model/brand'
  6. import { ConstKeys } from '~/enums/const-enums'
  7. import { useUserStore } from '@/stores/modules/user'
  8. const userStore = useUserStore()
  9. const { isLogin } = storeToRefs(userStore)
  10. const route = useRoute()
  11. const brandInfo = ref<any>()
  12. const goodsDetail = ref<any>()
  13. const crumbs = ref<any>([{ name: 'Home', url: '/' }])
  14. const quantityVisible = ref<boolean>(false)
  15. const inquireVisible = ref<boolean>(false)
  16. const id = route.params.id
  17. const { data, pending, error, refresh } = await useAsyncData(
  18. 'brand-detail',
  19. () =>
  20. $fetch(`${ConstKeys.DOMAINPRO}/client/merchandise/detail`, {
  21. params: { id },
  22. }),
  23. )
  24. const seoData = data.value?.result
  25. useHead({
  26. title: `Wholesale ${seoData?.merchandiseEnglishName} | EJET Selection`,
  27. meta: [
  28. {
  29. name: 'description',
  30. content: `Discover detailed information about premium wholesale products from trusted Chinese suppliers. Make informed decisions for your store with EJET Selection.`,
  31. },
  32. {
  33. property: 'og:title',
  34. content: `Wholesale ${seoData?.merchandiseEnglishName} | EJET Selection`,
  35. },
  36. {
  37. property: 'og:description',
  38. content: `Discover detailed information about premium wholesale products from trusted Chinese suppliers. Make informed decisions for your store with EJET Selection.`,
  39. },
  40. {
  41. property: 'og:type',
  42. content: 'website',
  43. },
  44. {
  45. property: 'twitter:title',
  46. content: `Wholesale ${seoData?.merchandiseEnglishName} | EJET Selection`,
  47. },
  48. {
  49. property: 'twitter:description',
  50. content: `Discover detailed information about premium wholesale products from trusted Chinese suppliers. Make informed decisions for your store with EJET Selection.`,
  51. },
  52. {
  53. property: 'twitter:card',
  54. content: 'summary_large_image',
  55. },
  56. ],
  57. link: [
  58. {
  59. rel: 'canonical',
  60. href: `${ConstKeys.DOMAINPRO}/product/${id}`,
  61. },
  62. ],
  63. })
  64. watch(() => isLogin.value, (v: any) => {
  65. if (!v)
  66. goodsDetail.value.sellPrice = 0
  67. })
  68. function getImgList(data: any) {
  69. const list = []
  70. if (data.masterImage)
  71. list.push(...data.masterImage.split(','))
  72. if (data.detailImage)
  73. return list.concat(...data.detailImage.split(','))
  74. return list
  75. }
  76. async function getGoodsDetail() {
  77. try {
  78. const data: any = await getGoodsDetailApi({ id })
  79. const list = getImgList(data)
  80. data.goodsImgOrVideoList = [...list]
  81. goodsDetail.value = data
  82. data.affiliationBrandId && getBrandInfo(data.affiliationBrandId)
  83. }
  84. catch (error) {
  85. console.log(error)
  86. }
  87. }
  88. async function getBrandInfo(id) {
  89. const info = await getBrandDetailApi({ id })
  90. brandInfo.value = info
  91. }
  92. getGoodsDetail()
  93. </script>
  94. <template>
  95. <div class="">
  96. <div class="w-1400px mx-auto pt-40px pb-60px">
  97. <div class="fw-300">
  98. <el-breadcrumb :separator-icon="ArrowRight">
  99. <el-breadcrumb-item
  100. v-for="(item, index) in crumbs" :key="index"
  101. :to="!!item.url ? { path: item.url } : null"
  102. >
  103. {{ item.name }}
  104. </el-breadcrumb-item>
  105. </el-breadcrumb>
  106. </div>
  107. </div>
  108. <div class="w-1400px mx-auto pb-50px flex">
  109. <business-goods-left :data="goodsDetail" />
  110. <business-goods-right :data="goodsDetail" @inquire="inquireVisible = true" @update:data="getGoodsDetail" @add-to-cart="quantityVisible = true" />
  111. </div>
  112. <div class="w-1400px mx-auto pb-100px ">
  113. <business-goods-attribute :data="goodsDetail" />
  114. </div>
  115. <business-goods-more-from-brand :brand-id="brandInfo?.id" :brand-info="brandInfo" />
  116. <business-goods-product-recommend :id="goodsDetail?.id" />
  117. <!-- <business-goods-similar-product :id="goodsDetail?.id" /> -->
  118. <business-goods-select-quantity v-if="quantityVisible" v-model:visible="quantityVisible" :data="goodsDetail" @update:data="getGoodsDetail" />
  119. <business-account-rfqs-quotation-modal v-if="inquireVisible" v-model:visible="inquireVisible" />
  120. <AppFooter />
  121. </div>
  122. </template>
  123. <style lang="less" scoped></style>